<div id="container">
<div contenteditable="true" id="sample">foo <input type="button" value="bar"> baz</div>
</div>
<script src="../../resources/js-test.js"></script>
<script>
function $(id) { return document.getElementById(id); }

var range = document.createRange();
range.setStartAfter(document.querySelector('input'));
var selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
document.execCommand('Delete');
document.execCommand('InsertText', false, 'quux');
shouldBeEqualToString('$("sample").innerHTML', 'foo quux&nbsp;baz');

if (window.testRunner)
    $('container').outerHTML = '';
</script>
</body>
